#pragma once
#include <iostream>

class Task
{
public:
    Task(int x, int y, char op)
    :sign_("+-*/"), x_(x), y_(y), op_(op), result_(0)
    {
        switch(op_)
        {
            case '+': result_ = x + y; break;
            case '-': result_ = x - y; break;
            case '*': result_ = x * y; break;
            case '/': result_ = x / y; break;    
        }       
    }

    int result()
    {
        return result_;
    }

    void record(std::string& r)
    {
        char buff[100];
        switch(op_)
        {
            case '+': snprintf(buff, sizeof(buff), "%d + %d = ?", x_, y_); break;
            case '-': snprintf(buff, sizeof(buff), "%d - %d = ?", x_, y_); break;
            case '*': snprintf(buff, sizeof(buff), "%d * %d = ?", x_, y_); break;
            case '/': snprintf(buff, sizeof(buff), "%d / %d = ?", x_, y_); break;    
        }     
        r = buff;
    }

    void operator()()
    {
        std::string task;
        record(task);
        std::cout << task << " 答案为：" << result() <<std::endl;
    }

    ~Task()
    {}
private:
    char sign_[5];
    int x_;
    int y_;
    char op_;
    int result_;
};